/**
 * Software Analysis and Verification 
 * @project: Verify Pattern Matching with Guards in Scala
 * @authors: Mirco Dotta and Philippe Suter
 */


package ch.epfl.lara.patterns.utils;

import ch.epfl.lara.patterns.ast.{Pattern, Var}


object TreePrinter {
  
  type Match = List[Pattern]
  
  private var indent = 0
  private val offsetInd = 3
  
  private def incInd = indent + offsetInd
  private def decInd = indent - offsetInd
  
  def apply(selector: (String,String), cases: Match) : Unit = {
    println(selector._1 + ": " + selector._2 + " { ")
    incInd
    cases foreach println
    decInd
    println("}")
  }

  private def println(pattern: Pattern) : Unit = {
    printIndent
    println(pattern.toString)
  }
  
  private def println(str: String) : Unit = {
    Console.println(str)
  }
  
  private def printIndent : Unit = 
    for (val i <- List(0,indent)) Console.print(" ")

}
